package dth.dao;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;

import dth.entity.Admin;
import dth.entity.Movie;

public class AdminDAO {
	private SessionFactory sessionFactory=new AnnotationConfiguration().configure().buildSessionFactory();
	private Session session=sessionFactory.openSession();
	public int insert(Admin admin){
		Transaction tx=session.beginTransaction();
		session.save(admin);
		tx.commit();
		return 1;
	}
	public java.util.List<Admin> getListAdmin(){
		session.beginTransaction();
		String queryString="select * from admin";
		Query query=session.createSQLQuery(queryString).addEntity(Admin.class);
		return query.list();
	}
}
